#include "ExponentialFader.h"


/********************************* settings ******************************/
// exponential decay factor
#define  EXPONENTIAL_FADE_FACTOR    0.95

// lower volume not distinguished from 0 (range is 0.0 100.0)
#define LOWER_VOLUME_LIMIT          1.0
/*************************************************************************/

ExponentialFader::ExponentialFader(QObject *parent) :
   Fader(parent)
{
}

void ExponentialFader::onVolumeUpdateTick()
{
   m_volume = m_volume * EXPONENTIAL_FADE_FACTOR;

   if( isFadeComplete() )
   {
      stop();
      m_volume = 0.0;
   }

   emit changeVolume( m_volume );
}

bool ExponentialFader::isFadeComplete()
{
   return  (m_volume < LOWER_VOLUME_LIMIT);
}
